/*
 * @Author: 郑亮 z17620994877@163.com
 * @Date: 2024-06-08 00:33:43
 * @LastEditors: 郑亮 z17620994877@163.com
 * @LastEditTime: 2024-08-21 11:21:25
 * @FilePath: \helloworld\src\extension.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import {createInterface} from './createInterface/create';
// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
export async function activate(context: vscode.ExtensionContext) {
	const disposable = vscode.commands.registerCommand('extension.sayHello', async (uri) => {
		const createUrl =  vscode.Uri.file(uri.path);
		const Uint8Array = await vscode.workspace.fs.readFile(createUrl);
		const Uint8Str = Uint8Array.toString();
		createInterface(Uint8Str);
		
		const interfaceStr = `interface obj {
			name: String
		}`;
		const rootPath = vscode.workspace.workspaceFolders![0].uri.path + '/interface.ts';
		console.log(rootPath)
		vscode.workspace.fs.writeFile(vscode.Uri.file(rootPath), new TextEncoder().encode(interfaceStr))
		.then(() => {
			console.log(123)
		}, (e) => {
			console.log(e)
		});
	});

	context.subscriptions.push(disposable);
}

// This method is called when your extension is deactivated
export function deactivate() { }
